package com.github.chirspan.xaas.gateway.web;

import com.github.chirspan.xaas.core.rest.RestResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * ************************
 * <p>版本信息接口</p>
 * *************************
 *
 * @author chenpan
 * @date 2021/1/19 15:31
 */
@RestController
@RequestMapping("/version")
public class VersionController {

    @Value("${spring.application.name:-}")
    private String application;

    @Value("${app.version:-}")
    private String version;

    /**
     * 打包时间
     */
    @Value("${app.build.time:-}")
    private String buildTime;

    @Value("${app.copyRight:-}")
    private String copyRight;

    @GetMapping
    public RestResult version() {
        Map<String, String> ret = new HashMap<>();
        ret.put("application", application);
        ret.put("version", version);
        ret.put("buildTime", buildTime);
        ret.put("copyRight", copyRight);

        return RestResult.OK(ret);
    }
}
